import { _decorator, Component, RigidBody2D, Vec2 } from 'cc';
import gameFruitUtils from './gameFruitUtils';
const { ccclass, property } = _decorator;

/**
 * 水果
 */
@ccclass('gameFruit')
export class gameFruit extends Component {

    forceHorzMin: number = 0;
    forceHorzMax: number = 1000;

    forceMin: number = 30000;
    forceMax: number = 35000;

    onLoad() {
        console.log("gameFruit onload")
    }

    init() {
        let rigidBodyFruit = this.node.getComponent(RigidBody2D)

        rigidBodyFruit.angularVelocity = 100;//默认的角速度
        let forceY = gameFruitUtils.generateRandomNumber(this.forceMin, this.forceMax);
        let forceX = gameFruitUtils.generateRandomNumber(this.forceHorzMin, this.forceHorzMax);
        rigidBodyFruit.applyForceToCenter(new Vec2(0, 5000), true);
        console.log("gameFruit init")
    }

    start() {

    }

    update(deltaTime: number) {

    }
}


